package com.ruoyi.web.wx.controller.pay;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.wx.pay.WxPayShareMapper;
import com.ruoyi.system.service.wx.pay.IWxPayShareMapperService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 支出分享映射Controller
 * 
 * @author mic
 * @date 2023-08-18
 */
@RestController
@RequestMapping("/wxPayShareMapper")
public class WxPayShareMapperController extends BaseController
{
    @Autowired
    private IWxPayShareMapperService wxPayShareMapperService;

    /**
     * 查询支出分享映射列表
     */
    @PreAuthorize("@ss.hasPermi('wxPayShareMapper:wxPayShareMapper:list')")
    @GetMapping("/list")
    public AjaxResult list(WxPayShareMapper wxPayShareMapper)
    {
        List<WxPayShareMapper> list = wxPayShareMapperService.selectWxPayShareMapperList(wxPayShareMapper);
        return success(list);
    }

    /**
     * 导出支出分享映射列表
     */
    @PreAuthorize("@ss.hasPermi('wxPayShareMapper:wxPayShareMapper:export')")
    @Log(title = "支出分享映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxPayShareMapper wxPayShareMapper)
    {
        List<WxPayShareMapper> list = wxPayShareMapperService.selectWxPayShareMapperList(wxPayShareMapper);
        ExcelUtil<WxPayShareMapper> util = new ExcelUtil<WxPayShareMapper>(WxPayShareMapper.class);
        util.exportExcel(response, list, "支出分享映射数据");
    }

    /**
     * 获取支出分享映射详细信息
     */
    @PreAuthorize("@ss.hasPermi('wxPayShareMapper:wxPayShareMapper:query')")
    @GetMapping(value = "/{belongId}")
    public AjaxResult getInfo(@PathVariable("belongId") String belongId)
    {
        return success(wxPayShareMapperService.selectWxPayShareMapperByBelongId(belongId));
    }

    /**
     * 新增支出分享映射
     */
    @PreAuthorize("@ss.hasPermi('wxPayShareMapper:wxPayShareMapper:add')")
    @Log(title = "支出分享映射", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxPayShareMapper wxPayShareMapper)
    {
        return toAjax(wxPayShareMapperService.insertWxPayShareMapper(wxPayShareMapper));
    }

    /**
     * 修改支出分享映射
     */
    @PreAuthorize("@ss.hasPermi('wxPayShareMapper:wxPayShareMapper:edit')")
    @Log(title = "支出分享映射", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxPayShareMapper wxPayShareMapper)
    {
        return toAjax(wxPayShareMapperService.updateWxPayShareMapper(wxPayShareMapper));
    }

    /**
     * 删除支出分享映射
     */
    @PreAuthorize("@ss.hasPermi('wxPayShareMapper:wxPayShareMapper:remove')")
    @Log(title = "支出分享映射", businessType = BusinessType.DELETE)
	@DeleteMapping("/{belongIds}")
    public AjaxResult remove(@PathVariable String[] belongIds)
    {
        return toAjax(wxPayShareMapperService.deleteWxPayShareMapperByBelongIds(belongIds));
    }
}
